package com.zq.server.api.dao;

import java.util.List;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import com.zq.server.api.domain.entity.ApiGroup;

/**
 * @author Super
 * @description 针对表【a_group】的数据库操作Mapper
 * @createDate 2024-02-25 20:49:08
 * @Entity .com.zq.daomain.entity.Group
 */
@Mapper
public interface GroupMapper {

    /**
     * 根据id获取组信息
     *
     * @param gid
     * @return Group
     */
    @Select("select * FROM  api_group where g_id = #{gid}")
    ApiGroup getByGIdGroup(Long gid);

    /**
     * get 活动所有组
     *
     * @param activityId
     * @return List<Group>
     */
    List<ApiGroup> selectGroupsByActivityId(Integer activityId);

    /**
     * 查看当前组是否满员
     */
    @Select("SELECT *  FROM api_group WHERE api_group.g_id = #{gid} and api_group.g_groupnumber = (SELECT count(*) FROM api_group_member WHERE gm_groupid = #{gid});")
    ApiGroup isGroupFull(@Param("gid") Long gid);


    boolean update(ApiGroup group);


    /**
     * 批量插入组
     *
     * @param groups
     */
    Boolean saveGroupList(List<ApiGroup> groupList);
}
